home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Tool Chest / Interfaces & Libraries / Interfaces / CIncludes / SANE.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-20  |  5.5 KB  |  242 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        SANE.h
  3.  
  4.     Copyright:    © 1983-1995 by Apple Computer, Inc.
  5.                 All rights reserved.
  6.  
  7.     Version:    MPW 3.4a3 for E.T.O. #18
  8.     Created:    Monday, June 19, 1995
  9.  
  10. */
  11.  
  12. #ifndef __SANE__
  13. #define __SANE__
  14.  
  15.  
  16. #ifndef __TYPES__
  17. #include <Types.h>
  18. #endif
  19.  
  20. #ifndef __MATH_H__
  21. #include <math.h>
  22. #endif
  23.  
  24.  
  25. #if GENERATINGCFM
  26.  
  27. #error "The SANE.h header can only be used for code using the Classic 68K runtime model."
  28.  
  29. #else
  30.  
  31.  
  32. #ifdef mc68881
  33.  
  34. /* specific to the MC68881 SANE library */
  35.  
  36. #define INEXACT ((exception)(8))
  37. #define DIVBYZERO ((exception)(16))
  38. #define UNDERFLOW ((exception)(32))
  39. #define OVERFLOW ((exception)(64))
  40. #define INVALID ((exception)(128))
  41. #define CURINEX1 ((exception)(256))
  42. #define CURINEX2 ((exception)(512))
  43. #define CURDIVBYZERO ((exception)(1024))
  44. #define CURUNDERFLOW ((exception)(2048))
  45. #define CUROVERFLOW ((exception)(4096))
  46. #define CUROPERROR ((exception)(8192))
  47. #define CURSIGNAN ((exception)(16384))
  48. #define CURBSONUNOR ((exception)(32768))
  49.  
  50. #else
  51.  
  52. /* specific to the software SANE library */
  53.  
  54. #define INVALID ((exception)(1))
  55. #define UNDERFLOW ((exception)(2))
  56. #define OVERFLOW ((exception)(4))
  57. #define DIVBYZERO ((exception)(8))
  58. #define INEXACT ((exception)(16))
  59. #define IEEEDEFAULTENV ((environment)(0))    /*IEEE-default floating-point environment*/
  60.  
  61. #endif                                        /* mc68881 */
  62.  
  63. /* The common interface to the SANE library */
  64.  
  65. /* Decimal Representation Constants */
  66.  
  67. #define SIGDIGLEN 20                        /* significant decimal digits */
  68. #define DECSTROUTLEN 80                     /* max length for dec2str output */
  69.  
  70. /* Decimal Formatting Styles */
  71.  
  72. #define FLOATDECIMAL ((char)(0))
  73. #define FIXEDDECIMAL ((char)(1))
  74.  
  75. /* Ordering Relations */
  76.  
  77. #define GREATERTHAN ((relop)(0))
  78. #define LESSTHAN ((relop)(1))
  79. #define EQUALTO ((relop)(2))
  80. #define UNORDERED ((relop)(3))
  81.  
  82. /* Inquiry Classes */
  83.  
  84. #define SNAN ((numclass)(0))
  85. #define QNAN ((numclass)(1))
  86. #define INFINITE ((numclass)(2))
  87. #define ZERONUM ((numclass)(3))
  88. #define NORMALNUM ((numclass)(4))
  89. #define DENORMALNUM ((numclass)(5))
  90.  
  91. /* Rounding Directions */
  92.  
  93. #define TONEAREST ((rounddir)(0))
  94. #define UPWARD ((rounddir)(1))
  95. #define DOWNWARD ((rounddir)(2))
  96. #define TOWARDZERO ((rounddir)(3))
  97.  
  98. /* Rounding Precisions */
  99.  
  100. #define EXTPRECISION ((roundpre)(0))
  101. #define DBLPRECISION ((roundpre)(1))
  102. #define FLOATPRECISION ((roundpre)(2))
  103.  
  104. #ifdef mc68881
  105.  
  106. typedef long exception;
  107.  
  108. struct environment {
  109.     long FPCR;
  110.     long FPSR;
  111. };
  112.  
  113. typedef struct environment environment;
  114.  
  115. extern environment IEEEDEFAULTENV;
  116.  
  117. struct trapvector {
  118.     void (*unordered)();
  119.     void (*inexact)();
  120.     void (*divbyzero)();
  121.     void (*underflow)();
  122.     void (*operror)();
  123.     void (*overflow)();
  124.     void (*signan)();
  125. };
  126.  
  127. typedef struct trapvector trapvector;
  128. #else
  129.  
  130. typedef short exception;
  131. typedef short environment;
  132. /* typedef struct {short w[6];} extended96;    -- Now defined in Types.h */
  133.  
  134. struct mischaltinfo {
  135.     unsigned short haltexceptions;
  136.     unsigned short pendingCCR;
  137.     long pendingD0;
  138. };
  139.  
  140. typedef struct mischaltinfo mischaltinfo;
  141. typedef pascal void (*haltvector)(mischaltinfo *misc, void *src2, void *src, void *dst, short opcode);
  142. #endif
  143.  
  144. typedef short relop;                        /* relational operator */
  145. typedef short numclass;                     /* inquiry class */
  146. typedef short rounddir;                     /* rounding direction */
  147. typedef short roundpre;                     /* rounding precision */
  148.  
  149. struct decimal {
  150.     char sgn;                                /*sign 0 for +, 1 for -*/
  151.     char unused;
  152.     short exp;                                /*decimal exponent*/
  153.     struct{
  154.         unsigned char length;
  155.         unsigned char text[SIGDIGLEN];        /*significant digits */
  156.         unsigned char unused;
  157.         }sig;
  158. };
  159.  
  160. typedef struct decimal decimal;
  161. struct decform {
  162.     char style;                             /*FLOATDECIMAL or FIXEDDECIMAL*/
  163.     char unused;
  164.     short digits;
  165. };
  166.  
  167. typedef struct decform decform;
  168. #ifdef __cplusplus
  169. extern "C" {
  170. #endif
  171.  
  172. #ifdef mc68881
  173.  
  174. struct trapvector gettrapvector(void);
  175. void settrapvector(const trapvector *v);
  176. void x96tox80(const extended *x,extended80 *x80);
  177. void x80tox96(const extended80 *x80,extended *x);
  178.  
  179. #else
  180.  
  181. haltvector gethaltvector(void); 
  182. void sethaltvector(haltvector v);
  183. void x96tox80(const extended96 *x96,extended *x);
  184. void x80tox96(const extended *x,extended96 *x96);
  185.  
  186. #endif
  187.  
  188. void num2dec(const decform *f,extended x,decimal *d);
  189. extended dec2num(const decimal *d); 
  190. void dec2str(const decform *f,const decimal *d,char *s);
  191. void str2dec(const char *s,short *ix,decimal *d,short *vp); 
  192. extended remainder(extended x,extended y,short *quo);
  193. extended rint(extended x);
  194. extended scalb(short n,extended x); 
  195. extended logb(extended x);
  196. extended copysign(extended x,extended y);
  197. extended nextfloat(extended x,extended y);
  198. extended nextdouble(extended x,extended y); 
  199. extended nextextended(extended x,extended y);
  200. extended log2(extended x);
  201. extended log1(extended x);
  202. extended exp2(extended x);
  203. extended exp1(extended x);
  204.  
  205. #define power(x,y) pow(x,y)
  206.  
  207. extended ipower(extended x,short i);
  208. extended compound(extended r,extended n);
  209. extended annuity(extended r,extended n);
  210. extended randomx(extended *x);
  211. numclass classfloat(extended x);
  212. numclass classdouble(extended x);
  213. numclass classcomp(extended x); 
  214. numclass classextended(extended x); 
  215. long signnum(extended x);
  216. void setexception(exception e,long s);
  217. long testexception(exception e);
  218. void sethalt(exception e,long s);
  219. long testhalt(exception e); 
  220. void setround(rounddir r);
  221. rounddir getround(void);
  222. void setprecision(roundpre p);
  223. roundpre getprecision(void);
  224. void setenvironment(environment e); 
  225. void getenvironment(environment *e);
  226. void procentry(environment *e); 
  227. void procexit(environment e);
  228. relop relation(extended x,extended y);
  229. extended nan(unsigned char c);
  230.  
  231. #define inf() __inf()
  232.  
  233. extended pi(void);
  234.  
  235. #ifdef __cplusplus
  236. }
  237. #endif
  238.  
  239. #endif
  240.  
  241. #endif
  242.